package com.imooc.service.impl;

import com.imooc.idworker.Sid;
import com.imooc.mapper.BgmMapper;
import com.imooc.pojo.Bgm;
import com.imooc.pojo.BgmExample;
import com.imooc.service.BgmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Zhou
 * @create 2020-11-19 14:50
 */
@Service
public class BgmServiceImpl implements BgmService {
    @Autowired
    private BgmMapper bgmMapper;

    @Autowired
    private Sid sid;

    @Override
    public List<Bgm> queryBgmList() {
        BgmExample bgmExample = new BgmExample();
        List<Bgm> bgms = bgmMapper.selectByExample(bgmExample);
        return bgms;
    }

    @Override
    public Bgm queryBgmById(String bgmId) {
        BgmExample bgmExample = new BgmExample();
        BgmExample.Criteria criteria = bgmExample.createCriteria();
        criteria.andIdEqualTo(bgmId);
        List<Bgm> bgms = bgmMapper.selectByExample(bgmExample);
        return bgms.isEmpty() ? null : bgms.get(0);
    }
}
